package com.basin.common.core.async.standard;

/**
 * @author: Sam ZHONG | sammy1997@aliyun.com
 */
public final class TaskCreator {

    private TaskCreator() {
    }

    public static <T> AbstractBaseTask<T> newInstance(Class<? extends AbstractBaseTask<T>> clazz) {
        try {
            AbstractBaseTask<T> instance = clazz.getDeclaredConstructor().newInstance();
            instance.open(); // 在这里调用open
            return instance;
        } catch (Exception e) {
            throw new RuntimeException("Failed to create instance of " + clazz.getName(), e);
        }
    }
}
